a bit refactor and fix issues
modify state and user related codes
final fix for alpha version