removed a lot of white space, fixed failed if loops