My attempt at functional java