better Algorithm