added service and incorporated it into controller