resolved unfortunately close error by adding onpause() and testing the insert query