Fix possible IndexError and add whitespace