smarter way to delegate which function is used