fixed all limitations

Fixed
1. Same variable names issue
2. Converted to fun from creating a new function
3. Warning messages issue fix.