split long method into smaller ones

so they are better testable in the future