fix calculating position