+ added "when" function