add helper function to avoid recursion