Initial import of simulate code