adding save javascript method