Refactored Code

Cleaned up code.