updating with more type checks