changed devicePixelRatio to a function