Final code - Edited -Done