fixed a bug with the max shift