Fix bug in BUtil.middle