added checks before installation as suggested by reddit.com/user/pearofducks