switched to q not recursion