fixes bug in type-checking