fixed some cast issues