Added log statement and fixed minor bug