split functions to smaller pieces