implemented the vending machine using flatMap instead of for comprehension with Peter Kneller's help.