fixed NullPointerExceptions at retrieve