working implementation - 1st iteration