clean up javascript functions. add func reference to
refactor javascript