fixed bug in recursive case