Refactor rectangle