Added more cases, separated input and output