input and output fully implemented.