fixed logical errors in solving method