tilde not being expanded correctly for some reason so switched to HOME and also added logic for if files are missing