Some improvments to solving algorithem