Updated for API

updated code to be easier and cleaner
Signed-off-by Justin Wiblin <The_lone_devil@justin-wiblin.tk