added null checks and @NotNull