consolidated the helper functions.