code was a little messy