change loop parameter to accomodate unsigned type