Added sdcard detection logic