bug fix on complete code