use imax fn instead of a macro with side-effects