Tidied up logic in simulator