Hacked together last functions