refactoring leaf rectangle