solver code