implemented global variables into code