added error checking on percentage