exit and main implemented