added exit and looping control
added the secret template file
general refactoring