Logger added. Please read the comments and merge with the existing code