Corrected casting issues

Corrected casting issues