Refactor and remove unecessary code in cpr.class.php