Refactored Helper functions