Code Refactored (not much, but a lot better)