Working, needs refactoring.