implemented movement and collision logic