fixed some cast exceptions