added jonathans code for competion