null pointers fixed - needs tunctional tests