Few useful cpp functions