Fixed potential class cast exception