minor changes to handle nulls