binary functor messy but working