Improve javascript