fixed bug with function calling