initial work. Needs testing