Small update to credential logic for more robustness