Shorten the code, transform input line into idiomatic python and remove debug lines.