fixed some nesting, probably going to look to struct rewrite