Refactoring and slim lined process.php code