a somewhat more pleasing solution to #29