Improves algorithm