Add some type checking + fixed a bad example