fixed bugs. now running successfully without crashes