Simplify and re-use pos setting code.