modified to handle words