fixed the function