added assumption about positive input amounts