added new functionality which makes list close if you click away