merge two function into one function