fixed hw1: threshold added