Fixed: when type was null, it crashed the application