Refactor complex method