ImperativeProgram.scala made better