Much faster now, working better but still has a mistake somewhere