Updated to use Briguy37's modification