ready to refactor javascript