Minor changes- including error handlings