added timer and pulled out globals