updated code - fixing bugs