this sol is really bad. exceeds callstack. will chnage