Refactor method to meet lab requirements