updated code - still inprogress