add value checks and null checks