Added better security checks