reorganized some function calls