Code Final Version