Removed duplicated code from if clauses.