Fixing issue with parameter expansion in bash script