Fix bug in main