Implemented action selection in JS