Refactoring clams.js