used ian's suggestion and moved everything to a new thread with a naive implementation