refactored get allocated string