Renamed main helper function