made some fixes.

need to call function with the proper scope.