bug fix on complete function