refactoring as suggested by codeclimate, looks more readable i think