encoding working correctly