asInstanceOf replaced with cast