Working-ish code for competition