Removed querying database twice

Changed:
generate_data executed database query twice if fields were provided.
Now it only does this once.