adding tim's code