easy mistakes, again because of using global, which is a terrible idea. major refactor needed.