VERY VERY BUGGY priority queue code (BACKUP BEFORE PULLING)