added a timer and fixed some button bugs