fixed a couple of bugs not the program finishes