use when instead of if