refactored if-end into one line