updated, now supports all types