added some nil checks for empty returns