Move fnUpdatePosition to a new file