refactor to separate files, fix 'has' syntax