getting there with the refactoring but still buggy