Not something you have to change, but I'm just making note that this function is pretty long and could be refactored.