Implements widget() function