working more on seperating code, added message handler