Added some security checks