Code Cleanup - Removed redundant code and added function descriptions