Added charge method that takes function as parameter.