Enable accepting arbitrary length of word

By modifying both the frontend and backend.