Main function
Main sim