re-wrote code per suggestion, much simpler