Slightly optimized, at least tested now against the client script in in the 6 second range