reorganize/update simulation code