made the functions work with the global array