Minor fix to the bugs cause by the previous fix