Corrected the function