fix NullPointerException by changing the implementation of init()