split code to funcs