non recursive (non hassle) solution