encode properties in a separate function