Update logic service

1. Refactored some codes
2. Update the comments and some variable’s name in order to be more
clear.