add more debug and exception handling to data transfer