Improve log in functions