removed unused function, changed scope of one function