updated APIhandler
merged local and remote APIhandler code