Position calculation refacted