initial code - lots of stuff needed ...