added functionality for tracking widths and heights arrays to improve performance