split the function into 3