Updated code with changed style and functions