add write and print functions