first solution for waterfall