Null pointer exception showing up in Generator class