refactoring - just split some functions