Implemented movement logic in the worker thread