cleaned up code, FINAL