changed code to work in bash