rewrote global_functions