bug fix, currently still does not work in scope of main fucntion