Reimplemented old code in angular