Abstracted out setPosition function as an instance method