reordered some functions