Fixing missing function to the code