Added functions with when conditions.

Note: all tests ok, except Bottles. Under investigation.