handling errors better and preserving comments