handling messages done; need to rewrite function names