added loops to prevent certain lines from being returned