refactor doll movement code