Move the calls inside the if conditional so that they can be short-circuited instead of always triggering a network call.