Mohsin: added wifi check and saved the data on SD Card