added more checking on the root type