added javascript implementation, bash implementation reworked