[M] refactored code