works but has stack issues