You could make this a lot more powerful with regular expressions, and take care of some of your limitations.