fixed mutiple bugs