Optimize input and output