New helper function