cleaning up helper function