added pseudo code for JS functionality