Add schemas code, second attempt.

Move this condition into the top if since the two else are both the same and get ride of the nested if.