fixed modal and error checking