incorporated sd write to record functionalty