added raw array writing code