there might be multiple keywords. need to iterate through them.

i also feel this function is growing too large. can we split it up.