Made changes to fix bugs