reverting previous commit and fixing the null exception

reverting previous commit and fixing the null exception