implemented the code fragments