another bug returning undefined instead of null