Updated and sorted code