CFY-606 refactor code and separate functionallity to different files