Seperating functions in js