merge 2 functions