working code with data sending