refactor and add composite type support