simplify when, close #18