Code optimize

- Remove unnecessary methods.
- Use case statement instead of if else.