Wasnt deleting length allocation in receivedata. Fixed it.