Improved position setup code