added encoding functions