fixes class cast bug