Completed percentOf function