fixed bug in next_restricted_part function -KL

next_restricted_part wasn't working correctly.