moved logging to method