Moved timer loop to better location