Updated code for moving objects