Removing repetition in log method