migrated code to be compatible with running server and client together