Prenex form - homework, bad coding, works