Updated code for #1 issue  1. and 3. error version with regex and split