parses input correctly, start formatting output