implemented the template code from Dr.Kang