Widget refactoring and null pointer error handled