functional main simulation