Improved and formated code