fixing js

moved code down