Added optional brackets for more clarity for the while loops and if statements.