fixed bug in the function