That way is correct, I don't know however if it is the best way out there so I am not sure if it is computationally expensive or optimal... Anyways, take a look at the code I posted once again for I've already added this information using the same idea !!!...