fixes bug on percentage calculation