added new code and fixed coms bugs