Refactored the Codes