Code Refactor and Update