code refactored (in accordance with style guide)