Another solution and some refactoring. creating classes for stuff. pro.