algorithmic changes, added input method