implemented write handler