Updated and Refactored