refactor rectangle