Fixed percent function
Updated for always include index