Extract helper functions