Replace log function, added comments