Complete working program