works with all datatypes and different depths