Helper functions used across all functions