added single end support
sub routine seems to be working