working, but make robust for variable image size