Working. Needs refactoring.