changed javascript call order