fix string comparison using equals

i have seen you are comparing strings using ==. I have replaced this using equals and also a null check