removing use of globals