Completed code for rudimentary type checking