implements if when functions