improve procedural algo