Move validating of displayedId to a method