2nd attempt, naveed modifications