Change code to Class for state and behaviour