bug fix with function calls