Fixed possible class cast exception