refactored moveTowards() method