fixed recursion problem