further implementation correction and debugging for project 3
late night updating project 3