I don't see any reason why in case of `cn=3` `scalarcn` should be `4`. Your solution works, but it looks worse in terms on code readability