tidying up the php file, keeping everything in blocks of code.