finfished code to handle sentences