updated implementaion