Add checks for null inputs