CleanUP and seperated code from admin.api.js