moving code for entering of build_dir globally instead on in the if block