Code Cleaned and Refactored