my coding may not be beautiful, but it works.