changed up logic for null checking