it is now working for negative integers as well