fixed varous bug