fixing class cast exception