removed urlopen, cleaned up code