Changed a bit to make it more implementable in a server