Fix bug in down sampling