Worked function. Look in to TODO