Moved player movement logic to separate function