cleaned up chunks of code