Use when instead of if