refactored client-side scripts