Fixes a bug when moving backward