Do you need num? Looks like it isn't used in the function.