Improved runtime slightly by using an arithmetic approach