Grouped similar functions into one function