Updated checkDataAndWait function and now uses new receive function in data class