Some refactoring for future modification (do not tested yet!!)