Refactored And Cleaned Up Code