also took functions out of tim's code