implementing solve functionallity