Refactor to reduce indents