API modules code revised (duplication and complexity solved)