fix shift calculation