Added checks for null values

Signed-off-by: Ruben <rubentin@gmail.com>