updated to api + selected files logic