bug fix for level and percent calculation