cleaned code for multi input