JS Function fix