fix bug calling functions