check for null and add some tests