Added compact() function