conforming to style guide and reducing nesting