refactoring of datatype code