fixed a problem with null references