Fixed code to be more readable and understandable