reordered main and helper functions, made more stuff shorter
made even more stuff shorter