refactor original code to fit monga