Style improvements - created registerEvents function