Added logic to fill in artificial and surplus array