modifed and added

couple of minor changes that should make it work better