adding logging to algorithm