Instead of saying 'task' say 'task beginner' and your thing will probably do it's job.
It probably works like it should, you just don't want it to work like this.
'if msgcontains(msg, 'task') then'
..
If the msg contains task then go on.. then immediately check if it also contains beginner etc.
Whatever, great that your script "doesn't work", but yea, I'm not into guessing what doesn't work.