made comments. updating logging function