split a function to several smaller ones