working finally, but has main loop that needs to go