Added null validation in classify method