fixed some minor bugs with for loops and added input control