Answers private fun getADvertise(onResult: (ArrayList) -> Unit = {}) { CoroutineScope(Dispatchers.IO).launch { //Do Request To get Data using retrofit val result = ArrayList()//result from retrofit withContext(Dispatchers.Main) { onResult(result) } } } private fun isProfileExist(): Boolean { //true or false return true } private fun getProfilePicture(id: String, OnResult: (String) -> Unit = {}) { CoroutineScope(Dispatchers.IO).launch { //Do Request To get Data using retrofit val result = "Link"//result from retrofit withContext(Dispatchers.Main) { OnResult(result) } } } //---------your main function------------------> public fun execute(onResultMain: (ArrayList) -> Unit = {}) { val exist = isProfileExist() if (exist) { getADvertise(onResultMain) } else { getProfilePicture("id") { getADvertise(onResultMain) } } } //onResultMain -> call back used to get result when they are ready ;)