Refactoring to eliminate returns where possible