Modified some logic and added try-run functionality.