Added checking for a null input