Slightly smarter version

Converted into angular way