Rewritten for removing the need to run it as root