Re-arrange functions for robustness