added to the writefunction subroutine