refactored codes to object/class/method