remove usage of defaultdict, return 1 and 0 instead of booleans