Fix position calculation