Improve simulation approach
A complete version with register feature

Many bugs