[fix] refactor some code for improved readability