replaced  with  and added global variable