improved main simulation