Changed the structure a bit to allow more flexibility. Defined input and output.