fixed null pointer while oppening database