Added check for perfomance.now before calling the function