Fixing wrong casting