CHANGED:cleaned up the codebase with  function