major algo improvement