Fix bug in handling None