make some refactoring and add fallback

also make some comments on how to improve the server