Refactored code for #4