refactored and created function for parameter scanning.