removed the trailing spaces in mode function