fine tuning & bug fixing; runs well on xSimulator