implemented first solution