copied ast functions for type checking