implemented counting and devise authentication