moved helper functions to top and linted