fix type & length function