save funtion works and writes to debug