optimize positions of inputs