borrowed from https://github.com/imulus/retinajs/blob/master/src/retina.js#L38