Switched to ints, sped up code