indentation fixed, finished changes to simulation code