Fixes maximum stack size exception