solve implementation