added while loop in main, fixes #1