reordering the functions to satisfy perls syntax requirements