Loop fixes

fix end commands and while ==false