refactor/cleanup of code