cleaned up code bigtime, it works now