put a few things in subroutines to save ram