reindent and refactor cond into if