added permission autodetect