Modified for negative integers