-write raw data function -> needs to be debugged