changed api and added better documentation