Add type checking and errors