example 3.1 with conditional statement