fixed NPE and compile warning