added write functionality