new implementation of reversing an integer