fixed severla bugs