implemented inits with foldr