added better new line handling