First working + tested version
Fixed error in JS