Helping a fellow classmate out, this is very badly commented and written code. Serves it's purpose though.