remove redundant if
refactor & reformat