added conditionals using closure

over-engineered, but trying to learn closures