There must be a more elegant way to write this code. Also, perhaps a way that actually works. I'm getting an error when I try to upload.