Another fix for cast exception