Can we use `List<Long>` here and get rid of the cast below?