Updated code with style and most working version