implmented typeCheck for writeFn