cleared up the logic a little
reindent