fixed cache and added data check