added encode to pre-actions