working on 'State' exercise from FP in Scala