server callback is now defined in smaller funtions