Completed initial working version for simulation