refactor long method