app.classify: removing duplicated code from the variable package