fix slice logic