added input and output functionality