fix type logic