final version(reformated code)