Trying to figure out why I'm getting a nan value