bugfix: now it works also for non-square rectangles