refator IMServer to a class as an IM Engine