Final code Opitimization