removed recursion function that causes errors