fixed a bug in shifting memory