Type checking implemented. Needs to be tested