refactored, removed to unnecessary variable and conditions