updated coding from niklas server