Fix 500 error rescue, add some variables to remove hardcoded numbers