updated
added working logic