maybe it's not pretty, but it works