refactored with single line if