Problem was the input, not the code