refactoring based on Todd's sugestions on code readability
refactoring if to single lines