modified to meet pset2 requirement