working! needs refactor.