fixed the previous bug in recursive call and introduced another one