Rewrote the last patch, hopefully it works this time