Revert "Changed main loop"

This reverts commit b2277579acd6b14a07d1753673a619804119ab39.