Add Events and put some code in separate files