finally fixed bug