change main code to work + some changes to bash script