refactored stuff. need to learn how to create unit tests.