working for sample input