updated to adapt to smaller resolutions