adapting the code to angular