reordered functions to improve file readability