changed the whole code for support for API version 3.