refactor to enforce types