first draft working, needs refactor