Update with help from @moddingmymind