MySQL Worbench Stored procedure problem

I am trying to create an mysql stored procedure with IF condition to UPDATE or INSERT in my table, the problem is that when I close the stored procedure the mysql workbench show that the last line “END” is with error when put the mouse in this line “Statement is incomplete, expecting IF”. My code:

CREATE PROCEDURE InsertUpdatePN1(IN prontuarioIN CHAR,
prontuario varchar(15),
data_consulta varchar(10),
nome varchar(300),
consulta_do_trimestre varchar(2))
BEGIN
IF EXISTS (SELECT * FROM tabela_exames_prenatal WHERE prontuario = prontuarionIN)
THEN BEGIN
UPDATE tabela_exames_prenatal
SET consulta_do_trimestre = ?;
END;
ELSE
BEGIN
INSERT INTO tabela_exames_prenatal
SET consulta_do_trimestre = ?;
END;
END
Thanks.

I located the problem, is that the “END IF” was missing, problem is solved.
Thanks.