Some documentation here on this logic would be good. Not sure what these magic numbers are trying to do