Added some type checks