updated with some extra minor changes for adding in type.