reworked main loop, app state removed