fixed gui bugs and made an end condition