combines two functions into one