added logic to split input