I found some ways to make this code more neat so I changed it