Use local variables in bash functions and get rid off env variables and use dir only