solve the problem of 'class for nil'