added a condition to check if local store object exists