updated with helper function