devide function from main