before refactor
finished code cleanup, things work much better now