Final code for second competition run