added case insensitivity to regex and tidied up a bit