Hacky first version, but works.