fixed null pointer and depricated method