Bug fix: use equals instead of ==
bug fix: perform size check of after null check