Added functions to write raw data