algorithm improvements