finally functional. Hopefully dependently typed later