make dependency check function so code is less repetitive with many checks
remove extraneous variable and command
add dependency check function, remove unneeded `clear`