Updated for API

improved and simplified code
Signed-off-by: Justin wiblin <the_lone_devil@justin-wiblin.tk>