Attempted fix of TypeError