Refactored this block into a method