not pretty, but it works!