Updated the code to work better, thanks @PeachyPeach for helping with the code long ago