fixes naming issue, fixes edge cases, also now output is in correct format