fixed probability and a few bugs