added third version of api, refactored two previous