added basic create functionality. fixed some logic issues.