Fixed bug regarding hardcoded ~ and replaced with Dir.home