completing the function