fixing: max stack size exceeded