Reduce complexity in compress method