fixed possible nullpointer
code qualtity improvements