working solution
everything is a fold