Latency issue w Yamaha MOX8?

Hey. Im using Yamaha MOX8 keyboard with Cubase. After recording a MIDI track, I notice that my playing is like wayyy offbeat. Like wayyy before the beat. Is this due to a latency issue? I have noticed that if I have on the keyboard VST Record set on and Daw level turned up, there is like a latency in the playback. Like the same sound is coming from two places at once, one slightly before the other. If I place it to VST Play instead, there is no ‘double sound’ but the sound of the note plays slightly after I press the key.

How to fix this? Or at the very least figure out how much the latency is (so I can simply move the MIDI event forward after I’ve recorded it)?

Thank you in advance.