Fixed exit of the program, not very elegant