full implementaiton