refactor; fixed bug where lone open brace would cause inf loop