moved todos to functions and made smarter