moved and renamed javascript functions