Bugfix for issue #6

$idexpand must be splitted before perm check