Fix matches NoneType error