finished elp function