Refactored codes.