added the ifloor to x to ensure same values if x is a fraction rather than an integer