added simulation and trial placement code