eliminating null pointer exception on API level