Attempted to fix casting bug