finished server side working on client side
decomposed client functions