added encoding parameter in initialization