modified a few things... tested mostly