refactor code to support pointer types
WIP