Adding null checks so this would work on the serrver