Functional finally, but not pretty