added simulation & fixed bugs