Fixing the class cast exception.