added api documentation
centralised core functionality