fixed bug and performance