writelog function added