First go at while and if; might've fixed some other stuff