refactored, cleanup, working