Code updated to make R check pass