Added more global declerations within functions