Javascript is working but is not executed