Fix bug with security check