Created getWord function