first functional version, but bad pretyprint