Fixed bug in updatePosition method