Input and output bugfixed