Added checks for braces at end of string