finally working well. but needs more testing to account for bugs.