Good point, this definitely is in need of some refactoring.