edited with solution