add more and better javascript null value checking