fix unexpected end of file error (properly close if/else block)