Fixing TypeError