moving some functions into init(), fixing 'next'