implementation of calcPosition method