reverse and forvard moving logic added