extract functions for clarity